// 供应商列表
import React from 'react';
import { Select } from 'antd';
import { connect } from 'dva';

const { Option } = Select;

@connect(({ publicdata: { nsSupplyList }, loading }) => ({
  nsSupplyList,
  loading: loading.effects['publicdata/fetchNsSupplyList'],
}))
class Supplier extends React.Component {
  componentDidMount() {
    const { dispatch, params = {} } = this.props;
    dispatch({
      type: 'publicdata/fetchNsSupplyList',
      payload: { name: null, ...params, type: 4 },
    });
  }

  render() {
    const { nsSupplyList = [] } = this.props;
    return (
      <Select
        placeholder="请输入关键字检索"
        {...this.props}
        showSearch
        optionFilterProp="children"
        notFoundContent="暂无数据"
        dropdownMatchSelectWidth={false}
        dropdownStyle={{ width: 300 }}
      >
        {nsSupplyList.map(item => (
          <Option key={item.suppId} fsOptions={item}>
            {item.name ? item.name : ''}
          </Option>
        ))}
      </Select>
    );
  }
}
export default Supplier;
